<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8 content detail">
      <div class="fly-panel detail-box">
        <h1>{$ques.title}</h1>
        <div class="fly-detail-info">
          <span class="layui-badge layui-bg-green fly-detail-column">{$ques.cname}</span>
          <span class="layui-badge" style="background-color: #999;">{$ques.status}</span>
          <div class="fly-admin-box" data-id="19942"></div>
          <span class="fly-list-nums">
            <a href="#comment">
              <i class="iconfont" title="回答"></i>{$ques.answer_num}</a>
            <i class="iconfont" title="人气"></i>{$ques.view_num}</span></div>
        <div class="detail-about">
          <a class="fly-avatar" href="/u/7893816/">
            <img src="__ROOT__/{$ques.face}" alt="73aasdqsd7"></a>
          <div class="fly-detail-user">
            <a href="/u/7893816/" class="fly-link">
              <cite>{$ques.nickname}</cite></a>
            <span><?php echo Ftime($ques['ctime']); ?></span></div>
          <div class="detail-hits" id="LAY_jieAdmin" data-id="19942">
            <span style="padding-right: 10px; color: #FF7200">悬赏：{$ques.kiss}飞吻</span>
            <?php if($ques['is_collect']){ ?>

             <span class="layui-btn layui-btn-xs jie-admin layui-btn-danger" type="collect" id='collect' qid = "{$ques.qid}" data-type="add">取消收藏</span>

            <?php }else{ ?>
             <span class="layui-btn layui-btn-xs jie-admin" type="collect" id='collect' qid = "{$ques.qid}" data-type="add">收藏</span>

            <?php } ?>
           
            </div>
        </div>
        <div class="detail-body photos">
          <?php if($ques['exct_info']){ ?>
          <?php $exct = json_decode($ques['exct_info'],true); ?>
          <table class="layui-table">
            <tbody>
              <tr>
                <td>版本：{$exct.project} {$exct.version}</td>
                <td>浏览器：{$exct.browser}</td></tr>
            </tbody>
          </table>

          <?php } ?>
          
          {$ques.content}
          </div>
      </div>
      <div class="fly-panel detail-box" id="flyReply">
        <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
          <legend>回帖</legend></fieldset>
        <?php if($answer) { ?>
         
        
        <ul class="jieda" id="jieda">
          {foreach $answer as $row}
          <li data-id="83696">
            <a name="item-1512184238264"></a>
            <div class="detail-about detail-about-reply">
              <a class="fly-avatar" href="/u/3198216/">
                <img src="__ROOT__{$row.face}" alt="驊驊龔頾"></a>
              <div class="fly-detail-user">
                <a href="/u/3198216/" class="fly-link">
                  <cite>{$row.nickname}</cite>
                  <i class="iconfont icon-renzheng" title="认证信息：layui 高级应用者"></i>
                  <i class="layui-badge fly-badge-vip">VIP2</i></a>
              </div>
              <div class="detail-hits">
                <span>{:Ftime($row['ctime'])}</span></div>
            </div>
            <div class="detail-body jieda-body photos">{$row.content}</div>
            <div class="jieda-reply">
              <span class="jieda-zan <?php if($row['is_zan']){ echo 'zanok';} ?>" aid="{$row.aid}" type="zan">
                <i class="iconfont icon-zan"></i>
                <em>{$row.zan_num}</em></span>
              <span type="reply">
                <i class="iconfont icon-svgmoban53"></i>回复</span>
            </div>
          </li>
          {/foreach}
        </ul>
        <?php }else{ ?>
          <ul class="jieda" id="jieda"> <li class="fly-none">消灭零回复</li> </ul>

        <?php }?>
        <div style="text-align: center"></div>
        <div class="layui-form layui-form-pane">
          <form action="/jie/reply/" method="post">
            <div class="layui-form-item layui-form-text">
              <a name="comment"></a>
              <div class="layui-input-block">
                
                <textarea id="L_content" name="content" required="" placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <input type="hidden" name="qid" value="{$ques.qid}">
              <button class="layui-btn" lay-filter="answer" lay-submit="">提交回复</button></div>
          </form>
        </div>
      </div>
    </div>
    <div class="layui-col-md4">
      <dl class="fly-panel fly-list-one">
        <dt class="fly-panel-title">本周热议</dt>
        <dd>
          <a href="/jie/19802/">Fly Template v3.0 发布，基于 layui 的极简社区模板</a>
          <span>
            <i class="iconfont icon-pinglun1"></i>77</span>
        </dd>
      </dl>
      <div class="fly-panel">
        <div class="fly-panel-title">心级赞助商
          <span style="padding: 0 3px;">-</span>
          <a href="/jie/15697/" class="fly-link fly-joinad    ">我要加入</a></div>
        <div class="fly-panel-main">
          <a href="http://core.fineui.com/" target="_blank" rel="nofollow" class="fly-zanzhu" style="background-color: #205B95;" time-limit="2017.07.17-2018.07.18">FineUI - 9 年控件库 + ASP.NET Core 2.0</a></div>
      </div>
      <div class="fly-panel">
        <div class="fly-panel-title">官方产品</div>
        <div class="fly-panel-main">
          <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">LayIM 3.0 - layui 旗舰之作</a></div>
      </div>
      <div class="fly-panel" style="padding: 20px 0; text-align: center;">
        <img src="//cdn.layui.com/upload/2017_8/168_1501894831075_19619.jpg" style="max-width: 100%;" alt="layui">
        <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p></div>
    </div>
  </div>
</div>
<script type="text/javascript">

  layui.use(['form','jquery','layer','layedit'],function  () {
      var form = layui.form;
      var $ = layui.jquery;
      var layer = layui.layer;
      var layedit = layui.layedit;

      layedit.set({
        uploadImage: {
          url: '{:url('index/jie/upload')}' //接口url
          ,type: 'post' //默认post
        }
      });

      index = layedit.build('L_content'); //建立编辑器


      form.on('submit(answer)', function(data){

        data.field.content = layedit.getContent(index);

        $.ajax({
          url: '{:url('index/jie/answer')}',
          type: 'POST',
          dataType: 'json',
          data: data.field,
        })
        .done(function(res) {

          if(res.error==1){
              layer.msg(res.info, function(){
              //关闭后的操作
              });
          }else{
            layer.alert(res.info, {icon: 6},function(){
              location.reload();
            });
          }
        })
        .fail(function() {
          console.log("error");
        })
        return false;
      });



      $('#collect').click(function(event) {

          that = $(this);
          qid = $(this).attr('qid');

          $.ajax({
            url: '{:url('index/jie/collect')}',
            type: 'POST',
            dataType: 'json',
            data: {qid:qid},
          })
          .done(function(res) {



            if(res.error==1){
                layer.msg(res.info, function(){
                //关闭后的操作
                });
            }else{
                if(res.info=='取消收藏'){
                  that.removeClass('layui-btn-danger');
                  that.text('收藏');
                }else{
                  that.addClass('layui-btn-danger');
                  that.text('取消收藏');
                }
            }
          })
          .fail(function() {
            console.log("error");
          })
          
      });


      $('.jieda-zan').click(function(event) {
            that = $(this);
            aid = $(this).attr('aid');

            $.ajax({
            url: '{:url('index/jie/zan')}',
            type: 'POST',
            dataType: 'json',
            data: {aid:aid},
          })
          .done(function(res) {
            if(res.error==1){
                layer.msg(res.info, function(){
                //关闭后的操作
                });
            }else{
                zan_num = parseInt(that.children('em').text());

                if(res.info=='取消点赞'){
                  that.removeClass('zanok');
                  zan_num--;
                  that.children('em').text(zan_num);
                }else{

                  that.addClass('zanok');
                  zan_num++;
                  that.children('em').text(zan_num);
                }
            }
          })
          .fail(function() {
            console.log("error");
          })
          
      });

    })

</script>